import Vue from "vue"
import VueRouter from "vue-router"
import login from "@/views/login"
// import cgDistribution from "@/views/admin/cgDistribution"
import AdminHome from "@/views/admin/AdminHome"
import index from "@/views/admin/index"


Vue.use(VueRouter);
const router = new VueRouter({
    mode: 'history',

    routes: [
        {
            path: '/', redirect: '/login'
        },
        {
            path: '/login', name: 'login', component: login
        },
        {
            path: '/adminHome',
            name: 'AdminHome',
            component: AdminHome,
            redirect: '/index',
            children: [
                {   path: '/index', component: index},
                {
                    path: '/campusInfoManagement/classManagement', component: () =>
                        import('@/views/admin/campusInfoManagement/classManagement'),
                },
                {
                    path: '/campusInfoManagement/majorManagement', component: () =>
                        import('@/views/admin/campusInfoManagement/majorManagement'),
                },
                {
                    path: '/campusInfoManagement/departmentManagement', component: () =>
                        import('@/views/admin/campusInfoManagement/departmentManagement/index'),
                },
                {
                    path: '/campusInfoManagement/dormitoryManagement', component: () =>
                        import('@/views/admin/campusInfoManagement/dormitoryManagement'),
                },
                {
                    path: '/campusInfoManagement/classArrangement', component: () =>
                        import('@/views/admin/campusInfoManagement/classArrangement/index'),
                },
                {
                    path: '/personnelManagement/roleManagement', component: () =>
                        import('@/views/admin/personnelManagement/roleManagement'),
                },
                {
                    path: '/personnelManagement/userManagement', component: () =>
                        import('@/views/admin/personnelManagement/userManagement'),
                },
                {
                    path: '/personnelManagement/menuManagement', component: () =>
                        import('@/views/admin/personnelManagement/menuManagement')
                },
                {
                    path: '/personnelManagement/infoImportManagement', component: () =>
                        import('@/views/admin/personnelManagement/infoImportManagement'),
                },
                {
                    path: '/studentManagement/studentsManagement', component: () =>
                        import('@/views/admin/studentManagement/studentsManagement'),
                },
                {
                    path: '/studentManagement/registerStatus', component: () =>
                        import('@/views/admin/studentManagement/registerStatus'),
                },
                {
                    path: '/studentManagement/dormitoryArrangement', component: () =>
                        import('@/views/admin/studentManagement/dormitoryArrangement'),
                },

            ]
        },
        {
            path: '/AddPaymentItems', name: 'AddPaymentItems', component: () => import('@/components/AddPaymentItems')
        },
        {
            path: '/stuLogin', name: 'stuLogin', component: () => import('@/views/stuLogin')
        },
        {
            path: '/homePage', name: 'homePage', component: () => import('@/views/student/homePage')
        },
        {
            path: '/arrivalRegistration', name: 'arrivalRegistration', component: () => import('@/views/student/ArrivalRegistration')
        },
        {
            path: '/notice', name: 'notice', component: () => import('@/views/student/Notice')
        },
        {
            path: '/mustRead', name: 'mustRead', component: () => import('@/views/student/MustRead')
        },
        {
            path: '/serviceHelp', name: 'serviceHelp', component: () => import('@/views/student/ServiceHelp')
        },
        {
            path: '/personalCenter', name: 'personalCenter', component: () => import('@/views/student/PersonalCenter')
        },
        {
            path: '/informationFilling', name: 'informationFilling', component: () => import('@/views/student/InformationFilling')
        },
        {
            path: '/registerInfo', name: 'registerInfo', component: () => import('@/views/student/RegisterInfo')
        },

    ]
});

// 挂载路由导航守卫
router.beforeEach((to, from, next) => {

    if (to.path === '/login') return next()
    if (to.path === '/register') return next()
    // 获取用户信息
    // const userInfo = JSON.parse(window.sessionStorage.getItem("user"))
    // if (!userInfo) return next('/login')
    next()

})

export default router
